class Table < ActiveRecord::Base
  belongs_to :dine
  TableOption = Struct.new(:id,:name)

  OPTIONS=[TableOption.new("TopTable","主桌"),TableOption.new("NormalTable","附桌")]

  def self.get_table_category(name)
    OPTIONS.each do |option|
      if option.id == name
        return option.name
      end
    end
    '没有这个餐桌类型'
  end

  def users_count
    count=0
    if self.eaters
      count=self.eaters.split(',').length
    end
    count
  end
  def users
    users=[]
    if self.eaters
      users=User.find(:all,:conditions=>"id in (#{self.eaters})")
    end
    users
  end
end
